//map高阶用法
//1.定义一个普通函数
const fn = () => {
	return new Promise((resolve, reject) => {
		let num = parseInt(Math.random() * 10000);
		setTimeout(() => {
			console.log(num);
			resolve(num);
		}, num);
	});
};
//2.注册多个任务
const arr = [];
arr.push(fn);
arr.push(fn);
arr.push(fn);
//3,获取最后一个任务
const final = arr.pop();
let tasks = arr.map(task => task());
Promise.all(tasks).then(() => {
	console.log('end');
});
